package nautilus.lab.activity;

import nautilus.lab.renderer.RendererOne;

import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.view.Menu;

public class TriangleActivity extends Activity 
{
	private GLSurfaceView mGLSurfaceView;
	
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        mGLSurfaceView = new GLSurfaceView(this);
        
        //check if the system support OpenGL ES
        final ActivityManager activityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
        final ConfigurationInfo configInfo = activityManager.getDeviceConfigurationInfo();
        final boolean supportEs2 = configInfo.reqGlEsVersion >= 0x20000;
        
        if(!supportEs2){
        	return;
        }
        
        //Request GLES 2.0 compatible context
    	mGLSurfaceView.setEGLContextClientVersion(2);
    	// Set the renderer to our demo renderer, defined below.
    	mGLSurfaceView.setRenderer(new RendererOne());
    	
    	//mGLSurfaceView.onTouchEvent(//event)
        
        //setContentView(R.layout.activity_main);
    	setContentView(mGLSurfaceView);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) 
    {
        //getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    
    @Override
    public void onPause()
    {
    	super.onPause();
    	mGLSurfaceView.onPause();
    }
    
    @Override
    public void onResume()
    {
    	super.onResume();
    	mGLSurfaceView.onResume();
    }
}
